package com.cbtx.tablet.ui

import android.os.Bundle
import com.bumptech.glide.Glide
import com.cbtx.tablet.App
import com.cbtx.tablet.R
import com.cbtx.tablet.bean.GoodsItemBean
import com.cbtx.tablet.constant.HttpConstant.DEVICE_WXQRCODE
import com.cbtx.utils.DeviceUtil
import com.cbtx.utils.zxing.ZxingUtils
import kotlinx.android.synthetic.main.activity_auth_detail.*

class AuthDetailActivity : AbsBaseActivity() {

    lateinit var authItem: GoodsItemBean

    override fun layoutId(): Int = R.layout.activity_auth_detail

    override fun initView(savedInstanceState: Bundle?) {

        authItem = intent.getSerializableExtra("authItem") as GoodsItemBean

        mTvCode.text = "云屏编码${App.androidId}"

        mTvBack.setOnClickListener {
            finish()
        }

        Glide.with(this)
            .load(authItem.coverImg)
            .error(R.mipmap.ic_default_small)
            .placeholder(R.mipmap.ic_default_small)
            .into(mIvCover)

        mTvTitle.text = authItem.goodsName
        mTvType.text = "藏品类别：" + if(authItem.category == null)"" else authItem.category
        mTvPrice.text = "藏品价格：${authItem.price}元"
        mTvTime.text = "藏品年代：${authItem.years}"

        val url = "${DEVICE_WXQRCODE}${DeviceUtil.getSerialNumber(this)}"
        mIvQRCode.setImageBitmap(ZxingUtils.createQRCode(url, 114, 0))
    }

    override fun initData(savedInstanceState: Bundle?) {

    }
}